﻿using Domain.Entity.Config;
using Domain.Repository.IConfig;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EFCore.Repository.Config
{
    public class Config_file_third_kindRepository : IConfig_file_third_kindRepository
    {
        private readonly MyDbContext myDbContext;

        public Config_file_third_kindRepository(MyDbContext myDbContext)
        {
            this.myDbContext = myDbContext;
        }
        public async Task<int> AddCFTKAsync(Config_file_third_kind config_File_Third_Kind)
        {
            myDbContext.config_File_Third_Kinds.Add(config_File_Third_Kind);
            return await myDbContext.SaveChangesAsync();
        }
       
        public async Task<int> DeleteCFTKAsync(int id)
        {
            Config_file_third_kind cftk = new Config_file_third_kind()
            {
                Ftk_id = id
            };
            myDbContext.config_File_Third_Kinds.Remove(cftk);
            return await myDbContext.SaveChangesAsync();
        }

        public async Task<List<Config_file_third_kind>> GetCFTKAsyncById(string kid)
        {
            return await myDbContext.config_File_Third_Kinds.Where(e=>e.Second_kind_id == kid).ToListAsync();
        }


        public async Task<int> UpdateCFTKAsync(Config_file_third_kind config_File_Third_Kind)
        {
            myDbContext.config_File_Third_Kinds.Update(config_File_Third_Kind);
            return await myDbContext.SaveChangesAsync();
        }

         public async  Task<List<Config_file_third_kind>> GetCFTKAsync()
        {
            return await myDbContext.config_File_Third_Kinds.ToListAsync();
        }
    }
}
